package cn.qingxuntech.console.controller

import cn.qingxuntech.console.entity.SspMedia
import cn.qingxuntech.console.model.R
import cn.qingxuntech.console.model.request.SspMediaRequest
import cn.qingxuntech.console.service.SspMediaService
import com.mybatisflex.core.paginate.Page
import com.mybatisflex.core.query.QueryWrapper
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import javax.management.Query

@RestController
@RequestMapping("/qx/console/v1/media")
class MediaController {

    @Autowired
    lateinit var sspMediaService: SspMediaService

    @PostMapping("page")
    fun page(@RequestBody sspMediaRequest: SspMediaRequest): R<Page<SspMedia>> {

        return R.success(sspMediaService.page(sspMediaRequest))
    }

    @PostMapping("list")
    fun list(): R<List<SspMedia>> {

        return R.success(sspMediaService.list())
    }

    @PostMapping("updateMediaCostRate")
    fun updateMediaCostRate(@RequestBody sspMedia: SspMedia): R<Void> {

        sspMediaService.updateMediaCostRate(sspMedia)
        return R.success()
    }
}